const http = require('http')
const server = http.createServer()
server.on('request', (req,res) => {
    const url = req.url
    let htmlStr = '<h1>404 Not Found</h1>'
    if (url === '/' || url === 'index/html') {
        htmlStr = '<h1>首页</h1>'
    } else if (url === '/about.html') {
        htmlStr = '<h1>关于页面</h1>'
    }

    res.setHeader('Content-Type','text/html;charset=utf8')
    res.end(htmlStr)
})

server.listen(80, () => {
    console.log('启动服务器成功');
})